package com.comac.print.component.app.controller;

import com.alibaba.cola.dto.Response;

import com.comac.print.component.app.api.MasterPlateService;
import com.comac.print.component.app.cmd.MasterPlateCmd;
import com.comac.print.component.app.dto.MasterPlateDTO;
import com.comac.print.component.app.page.PageResponse;
import com.comac.print.component.app.qry.MasterPlateListQry;
import com.comac.print.component.app.qry.VersionListQry;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @Description 模板控制器
 * @Author yy
 * @Date 2022/4/7 17:35
 */
@Api("模板控制器")
@RestController
@Slf4j
public class MasterPlateController {

    @Autowired
    private MasterPlateService masterPlateService;

    @ApiOperation(value = "模板版本信息查询")
    @PostMapping(value = "/masterPlate/versionList")
    public List<MasterPlateDTO> versionList(@RequestBody VersionListQry versionListQry) {
        return masterPlateService.versionList(versionListQry);
    }
    @ApiOperation(value = "模板上传至oss")
    @PostMapping(value = "/masterPlate/uploadoss")
    public Response masterPlateFileupload(@NotNull MultipartFile file) {

        return masterPlateService.uploadToOss(file);
    }


    @ApiOperation(value = "模板信息上传")
    @PostMapping(value = "/masterPlate/save")
    public Response masterPlateUpload(@RequestBody MasterPlateCmd masterPlateCmd) {
        return masterPlateService.saveMasterPlate(masterPlateCmd);
    }


    @ApiOperation(value = "模板信息列表")
    @PostMapping(value = "/masterPlate/list")
    public PageResponse<MasterPlateDTO> masterPlateListQry(@RequestBody MasterPlateListQry masterPlateListQry) {
        return masterPlateService.qryMasterPlateList(masterPlateListQry);
    }

    @ApiOperation(value = "删除模板信息")
    @PostMapping(value = "/masterPlate/delete")
    public Response masterPlateDelete(@RequestBody MasterPlateCmd masterPlateCmd) {
        return masterPlateService.masterPlateDelete(masterPlateCmd);
    }

}
